//
//  NotificationViewController.swift
//  EasePods
//
//  Created by 李然 on 2024/5/7.
//

import UIKit
import EarbudsFunctions

class NotificationViewController: ViewController {
    
    let viewModel = NotificationViewModel()

    override func viewDidLoad() {
        super.viewDidLoad()

        self.navigation.item.title = R.string.localizable.setting_messages_title()
    }
    
    override func makeUI() {
        super.makeUI()
        
        self.view.backgroundColor = R.color.common_10_bg_page()
        
        view.addSubview(tipLabel)
        tipLabel.snp.makeConstraints { make in
            make.top.equalTo(navigation.bar.snp.bottom).offset(12)
            make.leading.equalTo(20)
            make.trailing.equalTo(-20)
        }
        
        view.addSubview(tableView)
        tableView.snp.makeConstraints { make in
            make.top.equalTo(tipLabel.snp.bottom).offset(12)
            make.leading.trailing.bottom.equalToSuperview()
        }
    }
    
    override func bindViewModel() {
        super.bindViewModel()
        
        viewModel.items.bind(to: self.tableView.rx.items(cellIdentifier: NotificatonSettingCell.reuseIdentifier, cellType: NotificatonSettingCell.self)) { _, item, cell in
            cell.bind(viewModel: item)
        }.disposed(by: rx.disposeBag)
    }
    
    lazy var tipLabel: UILabel = {
        let label = UILabel()
        label.textColor = R.color.common_3_text()
        label.font = Fonts.systemFont(ofSize: 12)
        label.numberOfLines = 0
        label.text = R.string.localizable.setting_messages_tip()
        return label
    }()

    lazy var tableView: TableView = {
        let view = TableView.init(frame: .zero, style: .plain)
        view.register(NotificatonSettingCell.self, forCellReuseIdentifier: NotificatonSettingCell.reuseIdentifier)
        view.rowHeight = 70
        view.separatorStyle = .none
        view.showsVerticalScrollIndicator = false
        view.backgroundColor = R.color.common_10_bg_page()
        return view
    }()
}


